package c.c.b.b.f;

import c.c.b.a.b.e;
import c.c.b.a.b.e0;
import c.c.b.a.b.v;
import c.c.b.a.b.y;
import c.c.b.a.b.z;
import c.c.b.a.b.z.b;
import java.io.FilterInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/* compiled from: OkStack */
public class n implements c.c.b.b.i.a {
    public final z a;

    /* compiled from: OkStack */
    public static class a extends FilterInputStream {
        public final e a;

        public a(e eVar) {
            super(eVar.q());
            this.a = eVar;
        }

        public void close() throws IOException {
            super.close();
            try {
                this.a.close();
            } catch (Throwable unused) {
            }
        }
    }

    public n() {
        b bVar = new b();
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        bVar.a(10000, timeUnit);
        bVar.c(10000, timeUnit);
        bVar.d(10000, timeUnit);
        this.a = new z(bVar);
    }

    public static List<a> b(v vVar) {
        if (vVar == null) {
            return new ArrayList();
        }
        ArrayList arrayList = new ArrayList(vVar.a());
        int a = vVar.a();
        for (int i = 0; i < a; i++) {
            String b = vVar.b(i);
            String d = vVar.d(i);
            if (b != null) {
                arrayList.add(new a(b, d));
            }
        }
        return arrayList;
    }

    public static e0 c(c cVar) throws c.c.b.b.h.b {
        byte[] body = cVar.getBody();
        if (body == null) {
            if (cVar.getMethod() != 1) {
                return null;
            }
            body = "".getBytes();
        }
        return e0.a(y.a(cVar.getBodyContentType()), body);
    }

    /* JADX WARNING: Removed duplicated region for block: B:11:0x0060  */
    /* JADX WARNING: Removed duplicated region for block: B:21:0x0091  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x00bb  */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x00db  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x0102  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x0144  */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x0140  */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x0138  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x012e  */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x0126  */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0120  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x011a  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x0114  */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x010a  */
    /* JADX WARNING: Removed duplicated region for block: B:71:0x01b1 A:{SYNTHETIC, Splitter:B:71:0x01b1} */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x016e A:{SYNTHETIC, Splitter:B:50:0x016e} */
    /* JADX WARNING: Removed duplicated region for block: B:77:0x01bd  */
    public c.c.b.b.f.b a(c.c.b.b.f.c<?> r10, java.util.Map<java.lang.String, java.lang.String> r11) throws java.io.IOException, c.c.b.b.h.a {
        /*
        r9 = this;
        r0 = r10.getTimeoutMs();
        r1 = r9.a;
        java.util.Objects.requireNonNull(r1);
        r2 = new c.c.b.a.b.z$b;
        r2.m976init(r1);
        r0 = (long) r0;
        r3 = java.util.concurrent.TimeUnit.MILLISECONDS;
        r2.a(r0, r3);
        r2.c(r0, r3);
        r2.d(r0, r3);
        r0 = 1;
        r2.u = r0;
        r2.t = r0;
        r1 = new c.c.b.a.b.z;
        r1.m979init(r2);
        r2 = r10.getUrl();
        r3 = 0;
        r4 = 0;
        if (r2 != 0) goto L_0x002e;
    L_0x002c:
        r2 = r4;
        goto L_0x0063;
    L_0x002e:
        r2 = new c.c.b.a.b.c0$a;
        r2.m934init();
        r5 = new java.net.URL;
        r6 = r10.getUrl();
        r5.<init>(r6);
        r6 = r5.getHost();
        r7 = android.text.TextUtils.isEmpty(r4);
        if (r7 != 0) goto L_0x005d;
    L_0x0046:
        r7 = new java.net.URL;	 Catch:{ Exception -> 0x005d }
        r8 = r5.toString();	 Catch:{ Exception -> 0x005d }
        r8 = r8.replaceFirst(r6, r4);	 Catch:{ Exception -> 0x005d }
        r7.<init>(r8);	 Catch:{ Exception -> 0x005d }
        r2.f(r7);	 Catch:{ Exception -> 0x005d }
        r7 = "Host";
        r2.g(r7, r6);	 Catch:{ Exception -> 0x005d }
        r6 = 1;
        goto L_0x005e;
    L_0x005d:
        r6 = 0;
    L_0x005e:
        if (r6 != 0) goto L_0x0063;
    L_0x0060:
        r2.f(r5);
    L_0x0063:
        if (r2 == 0) goto L_0x01c1;
    L_0x0065:
        r5 = r10.getUrl();
        if (r5 != 0) goto L_0x006c;
    L_0x006b:
        goto L_0x0082;
    L_0x006c:
        r5 = new java.net.URL;	 Catch:{ Exception -> 0x0082 }
        r6 = r10.getUrl();	 Catch:{ Exception -> 0x0082 }
        r5.<init>(r6);	 Catch:{ Exception -> 0x0082 }
        r5 = r5.getHost();	 Catch:{ Exception -> 0x0082 }
        r5 = java.net.InetAddress.getByName(r5);	 Catch:{ Exception -> 0x0082 }
        r5 = r5.getHostAddress();	 Catch:{ Exception -> 0x0082 }
        goto L_0x0084;
    L_0x0082:
        r5 = "";
    L_0x0084:
        r10.setIpAddrStr(r5);
        r5 = r10.getUserAgent();
        r5 = android.text.TextUtils.isEmpty(r5);
        if (r5 != 0) goto L_0x00b5;
    L_0x0091:
        r5 = new java.lang.StringBuilder;
        r5.<init>();
        r6 = r10.getUserAgent();
        r5.append(r6);
        r6 = " ";
        r5.append(r6);
        r6 = "okhttp/3.9.1";
        r5.append(r6);
        r5 = r5.toString();
        r6 = r2.c;
        r7 = "User-Agent";
        r6.a(r7);
        r2.g(r7, r5);
    L_0x00b5:
        r5 = r10.getHeaders();
        if (r5 == 0) goto L_0x00d9;
    L_0x00bb:
        r6 = r5.keySet();
        r6 = r6.iterator();
    L_0x00c3:
        r7 = r6.hasNext();
        if (r7 == 0) goto L_0x00d9;
    L_0x00c9:
        r7 = r6.next();
        r7 = (java.lang.String) r7;
        r8 = r5.get(r7);
        r8 = (java.lang.String) r8;
        r2.g(r7, r8);
        goto L_0x00c3;
    L_0x00d9:
        if (r11 == 0) goto L_0x00f9;
    L_0x00db:
        r5 = r11.keySet();
        r5 = r5.iterator();
    L_0x00e3:
        r6 = r5.hasNext();
        if (r6 == 0) goto L_0x00f9;
    L_0x00e9:
        r6 = r5.next();
        r6 = (java.lang.String) r6;
        r7 = r11.get(r6);
        r7 = (java.lang.String) r7;
        r2.e(r6, r7);
        goto L_0x00e3;
    L_0x00f9:
        r11 = r10.getMethod();
        r5 = "POST";
        switch(r11) {
            case -1: goto L_0x0144;
            case 0: goto L_0x0140;
            case 1: goto L_0x0138;
            case 2: goto L_0x012e;
            case 3: goto L_0x0126;
            case 4: goto L_0x0120;
            case 5: goto L_0x011a;
            case 6: goto L_0x0114;
            case 7: goto L_0x010a;
            default: goto L_0x0102;
        };
    L_0x0102:
        r10 = new java.lang.IllegalStateException;
        r11 = "Unknown method type.";
        r10.<init>(r11);
        throw r10;
    L_0x010a:
        r11 = c(r10);
        r4 = "PATCH";
        r2.d(r4, r11);
        goto L_0x0159;
    L_0x0114:
        r11 = "TRACE";
        r2.d(r11, r4);
        goto L_0x0159;
    L_0x011a:
        r11 = "OPTIONS";
        r2.d(r11, r4);
        goto L_0x0159;
    L_0x0120:
        r11 = "HEAD";
        r2.d(r11, r4);
        goto L_0x0159;
    L_0x0126:
        r11 = c.c.b.a.b.a.e.d;
        r4 = "DELETE";
        r2.d(r4, r11);
        goto L_0x0159;
    L_0x012e:
        r11 = c(r10);
        r4 = "PUT";
        r2.d(r4, r11);
        goto L_0x0159;
    L_0x0138:
        r11 = c(r10);
        r2.d(r5, r11);
        goto L_0x0159;
    L_0x0140:
        r2.a();
        goto L_0x0159;
    L_0x0144:
        r11 = r10.getPostBody();
        if (r11 == 0) goto L_0x0159;
    L_0x014a:
        r4 = r10.getBodyContentType();
        r4 = c.c.b.a.b.y.a(r4);
        r11 = c.c.b.a.b.e0.a(r4, r11);
        r2.d(r5, r11);
    L_0x0159:
        r11 = r2.h();
        r11 = r1.a(r11);
        r11 = (c.c.b.a.b.b0) r11;
        r11 = r11.a();
        r1 = r11.c;
        r2 = r11.g;
        r4 = -1;
        if (r1 == r4) goto L_0x01b1;
    L_0x016e:
        r10 = r10.getMethod();	 Catch:{ all -> 0x01b9 }
        r4 = 4;
        if (r10 == r4) goto L_0x0187;
    L_0x0175:
        r10 = 100;
        if (r10 > r1) goto L_0x017d;
    L_0x0179:
        r10 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        if (r1 < r10) goto L_0x0187;
    L_0x017d:
        r10 = 204; // 0xcc float:2.86E-43 double:1.01E-321;
        if (r1 == r10) goto L_0x0187;
    L_0x0181:
        r10 = 304; // 0x130 float:4.26E-43 double:1.5E-321;
        if (r1 == r10) goto L_0x0187;
    L_0x0185:
        r10 = 1;
        goto L_0x0188;
    L_0x0187:
        r10 = 0;
    L_0x0188:
        if (r10 != 0) goto L_0x0199;
    L_0x018a:
        r10 = new c.c.b.b.f.b;	 Catch:{ all -> 0x01b9 }
        r11 = r11.f;	 Catch:{ all -> 0x01b9 }
        r11 = b(r11);	 Catch:{ all -> 0x01b9 }
        r10.m1001init(r1, r11);	 Catch:{ all -> 0x01b9 }
        r2.close();
        return r10;
    L_0x0199:
        r10 = new c.c.b.b.f.b;	 Catch:{ all -> 0x01af }
        r11 = r11.f;	 Catch:{ all -> 0x01af }
        r11 = b(r11);	 Catch:{ all -> 0x01af }
        r3 = r2.o();	 Catch:{ all -> 0x01af }
        r4 = (int) r3;	 Catch:{ all -> 0x01af }
        r3 = new c.c.b.b.f.n$a;	 Catch:{ all -> 0x01af }
        r3.m1024init(r2);	 Catch:{ all -> 0x01af }
        r10.m1002init(r1, r11, r4, r3);	 Catch:{ all -> 0x01af }
        return r10;
    L_0x01af:
        r10 = move-exception;
        goto L_0x01bb;
    L_0x01b1:
        r10 = new java.io.IOException;	 Catch:{ all -> 0x01b9 }
        r11 = "Could not retrieve response code from HttpUrlConnection.";
        r10.<init>(r11);	 Catch:{ all -> 0x01b9 }
        throw r10;	 Catch:{ all -> 0x01b9 }
    L_0x01b9:
        r10 = move-exception;
        r0 = 0;
    L_0x01bb:
        if (r0 != 0) goto L_0x01c0;
    L_0x01bd:
        r2.close();
    L_0x01c0:
        throw r10;
    L_0x01c1:
        r10 = new java.lang.IllegalArgumentException;
        r11 = "request params maybe null";
        r10.<init>(r11);
        throw r10;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.b.f.n.a(c.c.b.b.f.c, java.util.Map):c.c.b.b.f.b");
    }
}
